import 'package:flutter/src/painting/box_shadow.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart';

import '../../config.dart';
import '../../ui/resources/colors.dart';


class Show {
  static void toast(String str, {duration = 2000, bool isI18n = true}) {
    EasyLoading.showToast(str);
  }

  static void snackbar(String title, String str) {
    Get.snackbar(title, str);
  }

  static void success(String str) {
    EasyLoading.showSuccess(str);
  }

  static void error(String str) {
    EasyLoading.showError(str);
  }

  static void info(String str) {
    EasyLoading.showInfo(str);
  }

  static void loading({String? str}) {
    if (str == null) {
      EasyLoading.show(status: "");
    } else {
      EasyLoading.show(status: str + "...");
    }
  }

  //val should be 0.0 ~ 1.0
  static void progress(double val, String str) {
    EasyLoading.showProgress(val, status: str);
  }

  static void dismiss() {
    EasyLoading.dismiss();
  }

  static void init() {
    EasyLoading.instance.loadingStyle = EasyLoadingStyle.custom;
    EasyLoading.instance.backgroundColor = JmColors.toastBg;
    EasyLoading.instance.indicatorColor = JmConfig.toastTextStyle.color;
    EasyLoading.instance.progressColor = JmConfig.toastTextStyle.color;
    EasyLoading.instance.textColor = JmConfig.toastTextStyle.color;
    EasyLoading.instance.animationStyle = EasyLoadingAnimationStyle.scale;
    EasyLoading.instance.boxShadow = <BoxShadow>[];
  }
}
